package com.ctvit.cch.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctvit.cch.core.mapper.InspirationRecordMapper;
import com.ctvit.cch.core.pojo.domain.InspirationRecord;
import com.ctvit.cch.core.pojo.vo.creative.InspirationRecordListVO;
import com.ctvit.cch.core.service.IInspirationRecordService;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * 灵感记录表 服务实现类
 *
 * @author heyingcheng
 * @date 2025/10/22
 */
@Service
public class InspirationRecordServiceImpl extends ServiceImpl<InspirationRecordMapper, InspirationRecord>
        implements IInspirationRecordService {

    @Override
    public List<InspirationRecordListVO> listByCreationId(String creationId) {
        LambdaQueryWrapper<InspirationRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(InspirationRecord::getCreationId, creationId);
        queryWrapper.orderByAsc(InspirationRecord::getCreateTime);
        return list(queryWrapper).stream().map(t -> {
            InspirationRecordListVO vo = new InspirationRecordListVO();
            BeanUtils.copyProperties(Objects.requireNonNull(t), vo);
            return vo;
        }).collect(Collectors.toList());
    }

}